package cn.zyy.jdbc;

import cn.zyy.utils.JDBCUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDemo06 {
    public static void main(String[] args) {

        Connection connection = JDBCUtil.getConnection();
        PreparedStatement pstmt = null;
        String sql = "update usr set username = ? where id = ?";
        try {
            pstmt = connection.prepareStatement(sql);
            //设置参数
            pstmt.setString(1, "赵六");
            pstmt.setInt(2, 4);
            int i = pstmt.executeUpdate();
            System.out.println("line = " + i);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtil.closeAll(null, pstmt, connection);
        }

    }
}
